<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" th:with="title='城市管理',active='article'">
<header th:replace="admin/header::headerFragment(${title},${active})"></header>
<body class="fixed-left">
<div id="wrapper">
    <div th:replace="admin/header::header-body"></div>
    <div class="content-page">
        <div class="content">
            <div class="container">
                <div class="row">
                    <div class="col-sm-12">
                        <h4 class="page-title">城市管理</h4>
                    </div>
                    <div class="col-md-12">
                        <table class="table table-striped table-bordered">
                            <thead>
                            <tr>
                                <th width="35%">编号</th>
                                <th width="15%">名称</th>
                                <th width="15%">简称</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <th:block th:each="post : ${pageInfo.list}">
                                <tr>
                                    <td>
                                        <th:block th:text="${post.id}"/>
                                    </td>
                                    <td><th:block th:text="${post.name}"/></td>
                                    <td><th:block th:text="${post.state}"/></td>

                                    <td>
                                        <a th:href="@{'/admin/city/edit/'+${post.id}}"
                                           class="btn btn-primary btn-sm waves-effect waves-light m-b-5"><i
                                                class="fa fa-edit"></i> <span>编辑</span></a>
                                        <a href="javascript:void(0)" th:onclick="'delPost('+${post.id}+');'"
                                           class="btn btn-danger btn-sm waves-effect waves-light m-b-5"><i
                                                class="fa fa-trash-o"></i> <span>删除</span></a>
                                    </td>
                                </tr>
                            </th:block>
                            </tbody>
                        </table>
                        <div class="clearfix">
                            <ul class="pagination m-b-5 pull-right">
                                <li th:if="${pageInfo.hasPreviousPage}">
                                    <a th:href="@{'?page='+${pageInfo.prePage}}" aria-label="Previous">
                                        <i class="fa fa-angle-left"></i>&nbsp;上一页
                                    </a>
                                </li>

                                <th:block th:each="nav : ${pageInfo.navigatepageNums}">
                                    <li th:class="${nav==pageInfo.pageNum}?'active':''"><a th:href="@{'?page='+${nav}}" th:text="${nav}"></a>
                                    </li>
                                </th:block>

                                <th:block th:if="${pageInfo.hasNextPage}">
                                    <li>
                                        <a th:href="@{'?page='+${pageInfo.nextPage}}" aria-label="Next">
                                            下一页&nbsp;<i class="fa fa-angle-right"></i>
                                        </a>
                                    </li>
                                </th:block>

                                <li><span th:text="'共'+${pageInfo.pages}+'页'"></span></li>
                            </ul>
                        </div>
                    </div>
                </div>
                <!--<div th:replace="admin/footer :: footer-content"></div>-->
            </div>
        </div>
    </div>
</div>
<div th:replace="admin/footer :: footer"></div>
<script type="text/javascript">
    /*<![CDATA[*/
    var tale = new $.tale();
    function delPost(cid) {
        tale.alertConfirm({
            title:'确定删除该文章吗?',
            then: function () {
                tale.post({
                    url : '/admin/city/delete',
                    data: {id: cid},
                    success: function (result) {
                        if(result){
                            tale.alertOkAndReload('城市删除成功');
                        } else {
                            tale.alertError('城市删除失败');
                        }
                    }
                });
            }
        });
    }
    /*]]>*/
</script>
</body>
</html>